﻿<Window x:Class="PointSelectorSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:wpf="http://schemas.microsoft.com/wpf/2008/toolkit"
		xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
    Title="Window1" WindowState="Maximized">
	<DockPanel>
		<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" HorizontalAlignment="Center">
			<StackPanel.Resources>
				<Style TargetType="{x:Type Button}">
					<Setter Property="Margin" Value="3"/>
				</Style>
				<Style TargetType="{x:Type RepeatButton}">
					<Setter Property="Margin" Value="3"/>
				</Style>
				<Style TargetType="{x:Type RadioButton}">
					<Setter Property="Margin" Value="3"/>
					<Setter Property="VerticalAlignment" Value="Center"/>
				</Style>
				<Style TargetType="{x:Type TextBlock}">
					<Setter Property="VerticalAlignment" Value="Center"/>
				</Style>
			</StackPanel.Resources>
			
			<StackPanel Margin="0,0,50,0" Orientation="Horizontal">
				<RepeatButton Content="Undo" Command="{x:Static ApplicationCommands.Undo}" CommandTarget="{Binding ElementName=plotter}"/>
				<RepeatButton Content="Redo" Command="{x:Static ApplicationCommands.Redo}" CommandTarget="{Binding ElementName=plotter}"/>
			</StackPanel>
			
			<TextBlock Margin="3,3,5,3" VerticalAlignment="Center">Mode:</TextBlock>
			<RadioButton Content="Add" Command="{Binding ChangeModeCommand, ElementName=selector}" CommandParameter="Add"/>
			<RadioButton Content="Remove" Command="{Binding ChangeModeCommand, ElementName=selector}" CommandParameter="Remove"/>
			<RadioButton Content="None" Command="{Binding ChangeModeCommand, ElementName=selector}" CommandParameter="None"/>

			<TextBlock Margin="50,3,0,3" Text="MaxPointsCount="/>
			<TextBox Margin="0,3,3,3" Text="{Binding MaxPointsCount, ElementName=selector, Mode=TwoWay}"/>
		</StackPanel>
		
		<Grid DockPanel.Dock="Bottom">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="3*"/>
				<ColumnDefinition Width="Auto"/>
			</Grid.ColumnDefinitions>

			<d3:ChartPlotter Name="plotter" Grid.Column="0" Visible="-200,-100,400,200" Background="White">
				<d3:AdjustablePointSelector x:Name="selector" MaxPointsCount="3"/>
				<d3:Map>
					<d3:OpenStreetMapServer/>
				</d3:Map>
				<d3:RectangleHighlight Bounds="0.3,0.3,0.4,0.4"/>
				
				<Button Content="Clear points" Name="ClearPointsBtn" Click="ClearPointsBtn_Click"/>
			</d3:ChartPlotter>

			<wpf:DataGrid Grid.Column="1" HorizontalAlignment="Right"
				ItemsSource="{Binding Path=Points, ElementName=selector}" AutoGenerateColumns="False">
				<wpf:DataGrid.Columns>
					<wpf:DataGridTextColumn Header="X" Binding="{Binding X}"/>
					<wpf:DataGridTextColumn Header="Y" Binding="{Binding Y}"/>
				</wpf:DataGrid.Columns>
			</wpf:DataGrid>
		</Grid>
	</DockPanel>
</Window>
